layui.use(['element', 'table', 'form','laydate'], function () {
        var $ = layui.$;
        var table = layui.table;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#updateDate',
            type: 'date',
            trigger: 'click'
        });
        getTable();
        function getTable (){
            $.ajax({
                url: "/courseTable/getAllJournal",
                type: "post",
                dataType: "json",
                success: function (data) {
                    tablereload(data.data);
                }
            })
        }
        function tablereload(data) {
            table.render({
                elem: '#table',
                data: data,
                title: '数据列表',
                limit: 10,
                toolbar: '#toptool',
                page: {
                    layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
                    first: "首页",
                    last: "尾页",
                },
                size: 'lg',
                cols: [[//定义列
                    {type: 'checkbox'},//复选框靠左
                    {field: 'courseId', title: '课程编号', align: 'center'},
                    {field: "courseName", title: "课程名称", align: 'center'},
                    {field: 'coursePrice', title: "商品原价", align: 'center',
                        templet: function (data) {
                            return data.coursePrice+" 元";
                        }
                    },
                    {field: 'courseNprice', title: "商品现价", align: 'center',
                        templet: function (data) {
                            return data.courseNprice+" 元";
                        }
                    },
                    {field: '', title: "操作时间", align: 'center',
                        templet: function (data) {
                            var user="<p>"+data.updateDate+"</p>"
                            return user;
                        }
                    },
                ]],
            });
        }
        //搜索
        search = function search() {
            var courseId = $('input[name=courseId]').val();
            var courseName = $('input[name=courseName]').val();
            var updateDate = $('input[name=updateDate]').val();
            var param = {
                'courseId':courseId,
                'courseName':courseName,
                "updateDate":updateDate
            }
            getTable2(param);
            function getTable2 (param){
                $.ajax({
                    url: "/courseTable/getAllJournal",
                    type: "post",
                    dataType: "json",
                    data:{
                        'courseId':param.courseId,
                        'courseName':param.courseName,
                        "updateDate":param.updateDate
                    },
                    success: function (data) {
                        tablereload(data.data);
                    }
                })
            }
        }
    }
);

//刷新
function Refresh() {
    location.reload();
}

//跳转
function goBack() {
    window.location.href = '/course/course-list.html';
}